package com.qf.game.dao;

import com.qf.framwork.base.BaseDao;
import com.qf.game.entity.Orders;

import java.util.List;

/**
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
public class OrdersDao extends BaseDao {

    public int insertOrders(Orders orders){
        String sql = "insert into orders(order_id, pid, money, happey_bean) value(?,?,?,?)";
        return super.insert(sql, orders.getOrderId(), orders.getPid(), orders.getMoney(), orders.getHappeyBean());
    }

    public Orders getOrdersById(Integer oid){
        String sql = "select * from orders where id = ?";
        return (Orders) super.queryOne(sql, Orders.class, oid);
    }

    public Orders getOrdersByOid(String orderId){
        String sql = "select * from orders where order_id = ?";
        return (Orders) super.queryOne(sql, Orders.class, orderId);
    }

    public int updateOrders(Orders orders) {
        String sql = "update orders set update_time = ?, status = ? where id = ?";
        return super.update(sql, orders.getUpdateTime(), orders.getStatus(), orders.getId());
    }

    public List<Orders> queryOrderList(Integer pid){
        String sql = "select * from orders where pid = ?";
        return super.queryPage(sql, Orders.class, pid);
    }
}
